package com.swj.modules.monitor.vo.server;

import com.swj.common.core.utils.BigDecimalUtil;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * CPU相关信息
 * 
 * @author ruoyi
 */

@NoArgsConstructor
@Data
public class Cpu {

    //核心数
    private int cpuNum;

    /**
     * cpu线程数
     */
    private int processors;

    //CPU总的使用率
    private double total;

    //CPU系统使用率
    private double sys;

    //CPU用户使用率
    private double used;

    //CPU当前等待率
    private double wait;

    //CPU当前空闲率
    private double free;

    public double getTotal() {
        return BigDecimalUtil.round(BigDecimalUtil.mul(total, 100), 2);
    }

    public double getSys() {
        return BigDecimalUtil.round(BigDecimalUtil.mul(sys / total, 100), 2);
    }

    public double getUsed() {
        return BigDecimalUtil.round(BigDecimalUtil.mul(used / total, 100), 2);
    }

    public double getWait() {
        return BigDecimalUtil.round(BigDecimalUtil.mul(wait / total, 100), 2);
    }

    public double getFree() {
        return BigDecimalUtil.round(BigDecimalUtil.mul(free / total, 100), 2);
    }

}
